using System;
using System.Collections.Generic;
using DevExpress.CodeRush.Core;
using CR.StyleCop;
using CR.StyleCop.Utils;
using DevExpress.CodeRush.StructuralParser;

namespace CR.StyleCop {

    public abstract class BaseStyleCopIssueSearcher<T> : BaseCodeIssueSearcher {

        public override void CheckCodeIssues(CheckCodeIssuesEventArgs ea) {
            if (ea.Scope == null)
                return;

            var issues = FindIssues(SourceUtils.GetElementEnumerator<T>(ea.Scope));
            foreach (var item in issues) {
                SourceUtils.AddIssue(ea, item);
            }
        }

        public abstract IEnumerable<StyleCopIssue> FindIssues(IEnumerable<T> elements);
    }

    public abstract class BaseStyleCopIssueSearcher<T1, T2, T3, T4, T5, T6, T7, T8, T9> : BaseCodeIssueSearcher {

        public override void CheckCodeIssues(CheckCodeIssuesEventArgs ea) {
            if (ea.Scope == null)
                return;

            var issues = FindIssues(SourceUtils.GetElementEnumerator<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ea.Scope));
            foreach (var item in issues) {
                SourceUtils.AddIssue(ea, item);
            }
        }

        public abstract IEnumerable<StyleCopIssue> FindIssues(IEnumerable<IElement> elements);
    }

}
